import React from 'react'

import Header from './Header.js'
import Footer from './Footer.js';

class News3 extends React.Component {
    constructor(props) {
        super(props);
        this.state = {  
            title: "这是一个新闻组件", 
            msg: "这是一个新闻组件msg"
        };
    }

    run = () => {
        alert("我是父组件的run方法")
    }

    getData = () => {
        alert(this.state.title);
    } 
    getChildData = (result) => {
        alert(result);
        this.setState({
            msg: result 
        });
    }
    getFooter = () =>{
        this.refs.footer.run(); 
    }
    render() {
        return (
            <div> 
                <Header title={this.state.title} run={this.run} news={this}/>
                <br/>
                <hr/>
                <br/>
                这是一个新闻组件的内容--{this.state.msg}
                <br/>
                <hr/>
                <br/>
                <button onClick={this.getFooter}>获取整个底部组件</button>
                <Footer ref='footer'/>
            </div>
        );
    }
}

export default News3;